package com.easygem.controller.front;

import com.easygem.front.service.CustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.Map;

/**
 * @author 肖智
 * @version 1.08
 * @Description TODO
 * @date 2025/1/3
 */
@Api(tags = "客户转移")
@RestController
@RequestMapping("/shiftClient")
public class ShiftClientController {
    @Autowired
    private CustomerService customerService;

    @ApiOperation(value = "批量分配资源给用户", notes = "将资源分配给用户")
    @PutMapping("/assignResources")
    @RequiresPermissions({"customer:shift"})
    public Integer assignResources(@RequestBody Map<String, Long[]> map) {
        // 调用服务层进行资源分配
        Long[] resourceIds = map.get("resourceIds");
        Long[] userIds = map.get("userIds");
        System.out.println("资源集合"+ Arrays.toString(resourceIds));
        System.out.println("用户集合"+ Arrays.toString(userIds));
        Integer result = customerService.clientShift(resourceIds, userIds);
        System.out.println("分配成功："+result);
        return result;
    }
}
